/**
 * Created by dh.huang on 2016/8/31.
 */
'use strict';

angular.module('inspinia')
  .controller('doctorHomeCtrl', function ($scope,users,$state,modelList) {

    $scope.patients= modelList.patientForDoctor;
    setTimeout(function () {
      $('#mainTable').trigger('footable_redraw');
    }, 100)


    $('body').addClass('mini-navbar');

    //init();
    function init() {
      $scope.search={};
      if (localStorage.getItem('regObj')) {
        $scope.patients = JSON.parse(localStorage.getItem('regObj'));
        $.each(modelList, function (i, val) {
          $scope.patients.push(val);
        })
        $scope.persons = $scope.patients;
        setTimeout(function () {
          $('#mainTable').trigger('footable_redraw');
        }, 100)
      } else {
        $scope.patients = [];
        $.each(modelList, function (i, val) {
          $scope.patients.push(val);
        })
        $scope.persons=$scope.patients;
        setTimeout(function () {
          $('#mainTable').trigger('footable_redraw');
        }, 100)
      }
    };

    $scope.searchItem=function (status) {
      $scope.persons=[];
      $.each($scope.patients,function (i,val) {
        if(val.status==status){
          $scope.persons.push(val);
        }
      })
      setTimeout(function () {
        $('#mainTable').trigger('footable_redraw');
      }, 100)
    }
    $scope.openModelForm=function (person) {
      localStorage.setItem('modelMessages',JSON.stringify(person));
      $state.go('index.modelForm');
    }
    $scope.goValidate = function(){
      window.location.href = "#/index/validate";
    };
  });


